package com.atom.app.mvvm.ui.activities

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.atom.app.mvvm.Contacts
import com.tencent.mmkv.MMKV

@SuppressLint("CustomSplashScreen")
class SplashActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val intent: Intent
        val mmkv = MMKV.defaultMMKV()
        mmkv.encode(Contacts.tag_is_first, true) // 默认跳过介绍界面
        if (!mmkv.decodeBool(Contacts.tag_is_first)) {
            mmkv.encode(Contacts.tag_is_first, true)
            intent = Intent(this, WelcomeActivity::class.java)
        } else {
            if (mmkv.decodeBool(Contacts.tag_is_login)){
                intent = Intent(this, MainActivity::class.java)
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
            }else{
                intent = Intent(this, LoginActivity::class.java)
            }
        }
        startActivity(intent)
        finish()
    }
}
